package com.supermap.business.cloud.cust.menu;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.cloud.cust.menu.SysMenu;
import com.supermap.dubbo.api.cloud.cust.menu.SysMenuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * @author aqua
 * @desc
 * @date 2019年02月21 11:14
 * @email 1301584033@qq.com
 */
@Controller
@RequestMapping("/cloud/cust/menu")
public class SysMenuController {


    @Reference(timeout = 100000)
    private SysMenuService sysMenuService;

    @GetMapping("/getSysMenuCode")
    @ResponseBody
    public String getSysMenuCode(String code){
        return  sysMenuService.getSysMenuCode(code);
    }
    @GetMapping("/getSysMenuById")
    @ResponseBody
    public JSONUtil getSysMenuById(Integer menuId){
        return  sysMenuService.getSysMenuById(menuId);
    }

    @GetMapping("/getSysMenuTreeNodeList")
    @ResponseBody
    public JSONUtil getSysMenuTreeNodeList(String areaCode,Integer roleId){
        return  sysMenuService.getSysMenuTreeNodeList(areaCode,roleId);
    }

    @PutMapping("/insertSysMenu")
    @ResponseBody
    public JSONUtil insertSysMenu(@RequestBody SysMenu sysMenu){
        return  sysMenuService.insertSysMenu(sysMenu);
    }

    @PostMapping("/updateSysMenu")
    @ResponseBody
    public JSONUtil updateSysMenu(@RequestBody SysMenu sysMenu){
        return  sysMenuService.updateSysMenu(sysMenu);
    }


    //------------------------------------------------前端APP展示部分

    //前端APP查询菜单
    @GetMapping("/getSysMenuList")
    @ResponseBody
    public JSONUtil getSysMenuList(Integer userId){
        return sysMenuService.getSysMenuList(userId);
    }
    //定制功能查询
    @GetMapping("/getAreaSysMenuList")
    @ResponseBody
    public JSONUtil getCostomSysMenuList(String areaCode,Integer userId){
        return sysMenuService.getCostomSysMenuList(areaCode,userId);
    }
    //功能定制

    @PutMapping("/putCostomMenu")
    @ResponseBody
    public JSONUtil putCostomMenu(Integer menuid,Integer userId){
        return  sysMenuService.putCostomMenu(menuid,userId);
    }

    //取消定制功能
    @DeleteMapping("/delCostomMenu")
    @ResponseBody
    public JSONUtil delCostomMenu(Integer menuid,Integer userId){
        return  sysMenuService.delCostomMenu(menuid,userId);
    }

    //菜单区域分配查询
    @GetMapping("/getSysMenuArea")
    @ResponseBody
    public JSONUtil getSysMenuArea(Integer menuId){
        return  sysMenuService.getSysMenuArea(menuId);
    }

    //最终菜单保存
    @PutMapping("/putSysMenuArea")
    @ResponseBody
    public JSONUtil putSysMenuArea(Integer menuId,String areaCodes){
        return  sysMenuService.putSysMenuArea(menuId,areaCodes);
    }
}
